package com.suixun.controller;

import com.suixun.controller.base.BaseController;
import com.suixun.controller.vo.CaseDisplayVo;
import com.suixun.controller.vo.OfficialVo;
import com.suixun.domain.CaseDisplay;
import com.suixun.service.BannerService;
import com.suixun.service.CaseDisplayService;
import com.suixun.utils.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

@Controller
@RequestMapping("/caseDisplay")
public class CaseDisplayController extends BaseController {

    @Resource
    private CaseDisplayService caseDisplayService;
    @Resource
    private BannerService bannerService;

    @GetMapping("/index/{page}/{size}")
    public String index(@PathVariable Integer page, @PathVariable Integer size, Model model) {
        model.addAttribute("bannerList", bannerService.listBanners(null, 1));
        model.addAttribute("caseDisplayPage", caseDisplayService.pageExclusionContent(page, size, null, 1));
        return "schoolPartner";
    }

    @GetMapping("/get/{id}")
    public String get(@PathVariable Integer id, Model model) throws UnsupportedEncodingException {
        CaseDisplay caseDisplay = caseDisplayService.getById(id);
        if (caseDisplay != null) {
            get(new CaseDisplayVo(), caseDisplay, model);
        }
        return "single2";
    }
}
